<% if Order.all.length > 0 %>
<table cellspacing="10">
  <tr>
    <th></th>
    <th>Restaurant</th>
    <th>Bounty</th>
    <th>Cost</th>
    <th>Destination</th>
    <th>Content</th>
    <th>Customer</th>
    <th></th>
  </tr>

<% Order.all.each do |order| %>
  <% if order.user_id != current_user.id && !order.delivery_completed && !order.delivery_failed %>
	  <tr>
	    <td>
	      <% if !order.driver_id %>
	      <%= link_to 'Take order', take_url(:id => order.id), :confirm => 'Are you sure?' %>
	      <% else %>
	      Taken by <%= User.find(order.driver_id).first_name %>
	      <% end %>
	    </td>
	    <td><%= order.restaurant %></td>
	    <td><%= number_to_currency(order.bounty) %></td>
	    <td><%= number_to_currency(order.order_cost) %></td>
	    <td><%= order.order_destination %></td>
	    <td><%= truncate order.content, :length => 25 %></td>
	    <td><%= User.find(order.user_id).email %></td>
	    <td><%= link_to 'Details', order %></td>
	  </tr>
  <% end %>
<% end %>
</table>
<% else %>
No orders yet.
<% end %>
